<%--
  Created by IntelliJ IDEA.
  User: zjk
  Date: 2018-07-31
  Time: 21:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html>
<head>
    <title>新增合同</title>
    <link rel="shortcut icon" href="<c:url value="/easyui/css/images/favicon.ico" />"/>
    <link rel="stylesheet" href="<c:url value="/css/flipclock.css"/>"/>
    <link href="<c:url value="/css/CalcSS3.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/css/index.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui_animation.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/easyui_plus.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/insdep_theme_default.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/icon.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/easyui/css/font-awesome-4.7.0/css/font-awesome.min.css"/>" rel="stylesheet"
          type="text/css"/>
    <!-- 引入 ECharts 文件 -->
    <script src="<c:url value="/js/echarts.js"/>"></script>
    <!--放入自定义的图表-->
    <script src="<c:url value="/js/monitor.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.easyui.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/easyui/js/jquery.insdep-extend.min.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/js/utils/DateFormate.js"/>"></script>
    <link href="<c:url value=" /css/utils/utilsDatagrid.css"/>" rel="stylesheet" type="text/css"/>
    <link href="<c:url value="/css/utils/utilsForm.css"/>" rel="stylesheet" type="text/css"/>
</head>
<style>

</style>
<body>
<script>
    $(function () {
        $("#close").linkbutton({
            onClick: function () {
                $("#window").dialog("close");
                $("#window").dialog("destroy");
            }
        });
    });

</script>


<form id="dr5hx-contract-load-edit" method="post" enctype="multipart/form-data">
    <div class="form-div" style="text-align:center;width: 800px;">
        <div class="dd">
            <input type="hidden" name="contractId" value="" id="dr5hx-contract-load-edit-contractId"/>
            <input id="dr5hx-contract-load-edit-customer" name="customerName" class="easyui-textbox"
                   data-options="label:'客户',width:740,labelWidth:50,readonly:true">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-topic" name="contractTopic" class="easyui-textbox"
                   data-options="label:'主题',width:740,labelWidth:50">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-money" name="contractMoney" class="easyui-textbox"
                   data-options="label:'总金额',width:345,labelAlign:'right',labelWidth:70">
            <span style="display: inline-block;width: 40px;"></span>
            <input id="dr5hx-contract-load-edit-backmoney" name="orderBackMoney" class="easyui-textbox"
                   data-options="label:'回款金额',width:345,labelWidth:70,readonly:true">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-startdate" name="orderStartTime" class="easyui-datebox"
                   data-options="label:'开始日期',width:345,labelWidth:70">
            <span style="display: inline-block;width: 40px;"></span>
            <input id="dr5hx-contract-load-edit-overdate" name="orderOverTime" class="easyui-datebox"
                   data-options="label:'结束日期',width:345,labelWidth:70">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-contact" name="fkCustomerId1" class="easyui-combobox"
                   data-options="label:'联系人',width:345,labelAlign:'right',labelWidth:70,panelHeight:'auto'">
            <span style="display: inline-block;width: 40px;"></span>
            <input id="dr5hx-contract-load-edit-emp" name="contractEmpno1" class="easyui-combobox"
                   data-options="label:'所有者',width:345,labelAlign:'right',labelWidth:70,panelHeight:'auto'">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-contractnumber" name="contractNumber" class="easyui-textbox"
                   data-options="label:'订单号',width:345,labelAlign:'right',labelWidth:70">
            <span style="display: inline-block;width: 40px;margin: 0px;"></span>
            <input id="dr5hx-contract-load-edit-plan" name="fkPlanId1" class="easyui-combobox"
                   data-options="label:'计划',width:345,labelAlign:'right',labelWidth:70,panelHeight:'auto'">
        </div>
        <div class="dd">
            <select id="dr5hx-contract-load-edit-state" class="easyui-combobox" name="contractState"
                    data-options="label:'状态',editable:false, labelAlign:'right',labelWidth:70,width:345,panelHeight:85">
                <option>执行中</option>
                <option>意外中止</option>
                <option>完成</option>
            </select>
            <span style="display: inline-block;width: 40px;"></span>
            <input id="dr5hx-contract-load-edit-isrefund" name="contractIsRefund" class="easyui-textbox"
                   data-options="label:'是否退货',readonly:true,width:345">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-remark" name="contractRemark" class="easyui-textbox"
                   data-options="label:'备注',width:740,labelAlign:'right',labelWidth:70,multiline:'true', height: 80">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-accessory" class="easyui-filebox" style="width: 740px"
                   name="uploadfile"
                   data-options="label:'添加附件',labelWidth:'70',buttonText:'&nbsp&nbsp&nbsp&nbsp选择&nbsp&nbsp&nbsp&nbsp'">
        </div>
        <div class="dd">
            <input id="dr5hx-contract-load-edit-address" name="contractAddress" class="easyui-textbox"
                   data-options="label:'收货地址',width:740,multiline:'true', height: 80">
        </div>
        <br/>
        <br/>
        <table align="center" id="dr5hx-contract-load-edit-codetails"
               data-options="align:'center', toolbar:'#dr5hx-contract-load-edit-codetails-toolsbar'"
               class="easyui-datagrid"
               style="height:auto;width:800px">
            <thead>
            <tr class="datagrid-header-row">
                <th data-options="field:'productName',width:400,align:'center',formatter: function (value, row, index) {
                                                                return row.productionDetail.pname;}">品名
                </th>
                <th data-options="field:'productionNumber',width:'auto',align:'center',
                    formatter:function(value,row,index){
                    return row.productionDetail.pid;}">型号
                </th>
                <th data-options="field:'productionUnit',width:'auto',align:'center',
                    formatter: function (value, row, index) {return row.productionDetail.pwunit; }">
                    单位
                </th>
                <th data-options="field:'productAccount',width:'auto',align:'center',formatter: function (value, row, index) {
                    return row.coDetail.cOAmount;
                    }">数量
                </th>
                <th data-options="field:'productCompleteAccount',width:'auto',align:'center',
                    formatter: function (value, row, index) {
                    return row.coDetail.cOCompleteAccount;
                    }">已交付
                </th>
                <th data-options="field:'productPrice',width:'auto',align:'center', formatter: function (value, row, index) {
                    return row.coDetail.cOPrice;
                    }">单价
                </th>
                <th data-options="field:'productioMoney', width:'auto',align:'center',
                    formatter: function (value, row, index) {
                    return row.coDetail.cOMoney;
                    }">总金额
                </th>
                <th data-options="field:'cOTime', width:'auto',align:'center',
                    formatter: function (value, row, index) {
                    return row.coDetail.cOTime;
                    }">预计发货时间
                </th>
                <th data-options="field:'productRemark',width:'auto',align:'center',formatter: function (value, row, index) {
                    return row.coDetail.cORemark;
                    }">备注
                </th>
            </tr>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
    <!--工具栏-->
    <div id="dr5hx-contract-load-edit-codetails-toolsbar">
        <a id="dr5hx-contract-load-edit-codetails-toolsbar-add" class="easyui-linkbutton" plain="true"
           iconCls="icon-my_edit">添加</a>
        <a id="dr5hx-contract-load-edit-codetails-toolsbar-edit"
           class="easyui-linkbutton" plain="true"
           iconCls="icon-my_edit">修改</a>
        <a id="dr5hx-contract-load-edit-codetails-toolsbar-delete"
           class="easyui-linkbutton" plain="true"
           iconCls="icon-my_edit">删除</a>
    </div>
</form>
<div id="dr5hx-contract-load-edit-dialog"
     class="easyui-dialog" style="background-color:#EBEFF2;" data-options="iconCls:'icon-save2',
			width:800,
			height:250,
			closed:true,
			method:'post',
			bodyCls:'by',
			shadow:true,
			modal:true,
			buttons:'#dr5hx-contract-load-edit-dialog-button'">

</div>
<div id="dr5hx-contract-load-edit-dialog-button">
    <a href="#" id="dr5hx-contract-load-edit-dialog-button-save" class="easyui-linkbutton"
       data-options="iconCls:'icon-ok2'">保存</a>
    <a href="#" id="dr5hx-contract-load-edit-dialog-button-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel2',
    onClick:function(){
        $('#dr5hx-contract-load-edit-dialog').window('close');
    }">关闭</a>
</div>
<script>


    $("#dr5hx-contract-load-edit-codetails-toolsbar-add").linkbutton({
        onClick: function () {
            $("#dr5hx-contract-load-edit-dialog").dialog({
                href: '/saling/toContractDetailsForm',
                title: '增加详情',
                buttons: '#dr5hx-contract-load-edit-dialog-button'
            })
            $("#dr5hx-contract-load-edit-dialog-button-save").linkbutton({
                onClick: function () {
                    $('#dr5hx-addCODetails-Form').form({
                        url: '/saling/addCODetail',
                        onSubmit: function () {
                            var isValid = $(this).form('validate');
                            return isValid;
                        },
                        success: function (data) {
                            $('#dr5hx-contract-load-edit-dialog').window('close')
                            $('#dr5hx-contract-load-edit-codetails').datagrid('reload')

                        }
                    }).submit();
                }
            })
            $("#dr5hx-contract-load-edit-dialog").window('open')
        }
    });


    $("#dr5hx-contract-load-edit-codetails-toolsbar-edit").linkbutton({
        onClick: function () {
            var row = $("#dr5hx-contract-load-edit-codetails").datagrid('getSelected')
            if (row) {
                $("#dr5hx-contract-load-edit-dialog").dialog({
                    href: '/saling/editCODetail',
                    title: '修改详情',
                    onLoad: function () {
                        $.post('/saling/getOneCODetail', {coId: row.coDetail.cOId}, function (r) {
                            if (r) {
                                $('#dr5hx-editCOdetails-ProductName').textbox({value: r.productionDetail.pname})
                                $('#dr5hx-editCOdetails-ProductPrice').textbox({value: r.coDetail.cOPrice})
                                $('#dr5hx-editCOdetails-ProductAccount').textbox({value: r.coDetail.cOAmount})
                                $('#dr5hx-editCOdetails-ProductMoney').textbox({value: r.coDetail.cOMoney})
                                $('#dr5hx-editCOdetails-date').datebox({value: r.coDetail.cOTime})
                                $('#dr5hx-editCOdetails-remark').textbox({value: r.coDetail.cORemark})
                                $('#dr5hx-editCOdetailsForm-coDetailId').val(r.coDetail.cOId)
                            }

                        })

                    },
                });
                $("#dr5hx-contract-load-edit-dialog-button-save").linkbutton({
                    onClick: function () {
                        $('#dr5hx-editCOdetails-Form').form({
                            url: '/saling/doEditCODetail',
                            onSubmit: function () {
                                var isValid = $(this).form('validate');
                                return isValid;
                            },
                            success: function (data) {
                                $('#dr5hx-contract-load-edit-dialog').window('close')
                                $('#dr5hx-contract-load-edit-codetails').datagrid('reload')

                            }
                        }).submit();
                    }
                })
                $("#dr5hx-contract-load-edit-dialog").window('open')
            } else {
                $.messager.alert('提示', "请选中一行！！！")
            }


        }
    });
    $("#dr5hx-contract-load-edit-codetails").datagrid({
        singleSelect: true,
    })
    $("#dr5hx-contract-load-edit-codetails-toolsbar-delete").linkbutton({
        onClick: function () {
            var row = $("#dr5hx-contract-load-edit-codetails").datagrid("getSelected")
            if (row != null) {
                var index = $("#dr5hx-contract-load-edit-codetails").datagrid('getRowIndex', row);
                $("#dr5hx-contract-load-edit-codetails").datagrid('deleteRow', index)
                rows = JSON.stringify(row)
                $.post("/saling/deleteCOdetail", {
                        rows: rows,
                        contractId: row.coDetail.contract.contractId
                    },
                    function (result) {
                        if (result.success == true) {
                            $.messager.alert("提示", "success")
                        } else {
                            $.messager.alert("提示", result.messager)

                        }
                    }
                )

            } else {
                $.messager.alert("提示", "未选中行")
            }
        }

    })
</script>
</body>
</html>
